package leader.action;

import java.util.ArrayList;
import java.util.List;

import leader.service.DirectAwardService;

import com.opensymphony.xwork2.ActionContext;

import teacher.bean.Award;
import teacher.bean.Teacher;

public class DirectAwardStateAction {
	private List<Award> award;
	private int currentpage;
	private int endpage;
	private int count;
	private int pagesize;
	private int flag;
	public List<Award> getAward() {
		return award;
	}
	public void setAward(List<Award> award) {
		this.award = award;
	}
	public int getCurrentpage() {
		return currentpage;
	}
	public void setCurrentpage(int currentpage) {
		this.currentpage = currentpage;
	}
	public int getEndpage() {
		return endpage;
	}
	public void setEndpage(int endpage) {
		this.endpage = endpage;
	}
	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		this.count = count;
	}
	public int getPagesize() {
		return pagesize;
	}
	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}
	public int getFlag() {
		return flag;
	}
	public void setFlag(int flag) {
		this.flag = flag;
	}
	public String execute() {
		System.out.println("==============成果分页开始============");
		Teacher lea=(Teacher) ActionContext.getContext().getSession().get("leader");
    	DirectAwardService awa = new DirectAwardService();
    	Award acheve = new Award();
    	acheve.setState(0);
		pagesize = 10;
		count = awa.getCountOfDirectAwardByState(lea, acheve);
    	if(currentpage == 0) {
    		currentpage = 1;
    	}
    	int add = 0;
    	if(count%pagesize != 0) {
    		add = 1;
    	}
    	endpage = count/pagesize + add;
    	if(currentpage > endpage && endpage > 0) {
    		currentpage = endpage;
    	}
    	ActionContext.getContext().put("flag",3);
    	flag = 3;
		award = awa.selectSegregateDirectAwardByState(lea,acheve,(currentpage-1)*pagesize+1, pagesize);   	
		return "success";
	}
}
